/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package academia.gui.lista;

import academia.gui.TelaAtendente;
import academia.gui.cadastro.CadastroAtendente;
import academia.persistencia.DBAcademia;
import academia.persistencia.PessoaDAO;
import academia.pessoal.Cliente;
import academia.pessoal.Pessoa;
import java.sql.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;
import net.proteanit.sql.DbUtils;

/**
 *
 * @author Guilherme
 */
public class ListarCliente extends javax.swing.JFrame {

    String tipo = "Cliente";

    /**
     * Creates new form ListarCliente
     */
    public ListarCliente() {
        initComponents();

    }
//   
    private void Update_Table() {
<<<<<<< .mine
   
    try{
       int linha = TabelaTeste.getSelectedRow();
       String Tabela_Click = TabelaTeste.getModel().getValueAt(linha, 0).toString();
       String sql= "SELECT * FROM Pessoa WHERE Tipo='Cliente'";
       ps=conn.prepareStatement(sql);
       rs=ps.executeQuery();
       
    }catch(Exception e){
        JOptionPane.showMessageDialog(null,e);
        
    }finally{
                 try {
                      rs.close();
                      ps.close();
                      } catch (SQLException ex) {
                            Logger.getLogger(ListarCliente.class.getName()).log(Level.SEVERE, null, ex);
                      }
=======
//   
//    try{
//       String sql= "SELECT * FROM Pessoa WHERE Tipo='Cliente'";
//       ps=conn.prepareStatement(sql);
//       rs=ps.executeQuery();
        PessoaDAO dao = new PessoaDAO();
        Pessoa pessoa = new Cliente();
        dao.listar(tipo);
        //TabelaTeste.setModel(DbUtils.resultSetToTableModel(pessoa));
//    }catch(Exception e){
//        JOptionPane.showMessageDialog(null,e);
//        
//    }finally{
//                 try {
//                      rs.close();
//                      ps.close();
//                      } catch (SQLException ex) {
//                            Logger.getLogger(ListarCliente.class.getName()).log(Level.SEVERE, null, ex);
//                      }
>>>>>>> .r144
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jButton1 = new javax.swing.JButton();
        scrollPane1 = new java.awt.ScrollPane();
        jScrollPane1 = new javax.swing.JScrollPane();
        TabelaTeste = new javax.swing.JTable();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jButton1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jButton1.setText("Voltar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        TabelaTeste.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null}
            },
            new String [] {
                "Title 1", "Título 2", "Título 3", "Título 4", "Título 5", "Título 6", "Título 7", "Título 8", "Título 9", "Título 10", "Título 11", "Título 12", "Título 13", "Título 14"
            }
        ));
        TabelaTeste.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                TabelaTesteMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(TabelaTeste);

        scrollPane1.add(jScrollPane1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(302, Short.MAX_VALUE)
                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(57, 57, 57))
            .addComponent(scrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(scrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 181, Short.MAX_VALUE)
                .addGap(115, 115, 115)
                .addComponent(jButton1)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        new TelaAtendente().setVisible(true);
        this.dispose();
    }//GEN-LAST:event_jButton1ActionPerformed

    private void TabelaTesteMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_TabelaTesteMouseClicked
//        try {
//
//            int linha = TabelaTeste.getSelectedRow();
//            String Tabela_Click = TabelaTeste.getModel().getValueAt(linha, 0).toString();
//            String sql = "SELECT * FROM PESSOA WHERE IDpessoa='" + Tabela_Click + "'";
//            ps = conn.prepareStatement(sql);
//            rs = ps.executeQuery();
//            if (rs.next()) {
//                int IDpessoa;
//                String id = rs.getString("IDpessoa");
//                System.out.println(id);
//            } funcao q retorna o id com o click do mouse
//        } catch (Exception e) {
//        } finally {
//            try {
//                rs.close();
//                ps.close();
//            } catch (SQLException ex) {
//                Logger.getLogger(ListarCliente.class.getName()).log(Level.SEVERE, null, ex);
//            }
//
//        }
    }//GEN-LAST:event_TabelaTesteMouseClicked
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTable TabelaTeste;
    private javax.swing.JButton jButton1;
    private javax.swing.JScrollPane jScrollPane1;
    private java.awt.ScrollPane scrollPane1;
    // End of variables declaration//GEN-END:variables
}
